package com.lxmes.base.service.impl;

import java.util.List;

import com.lxmes.common.exception.ServiceException;
import com.lxmes.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.lxmes.base.mapper.JcWarehouseinfoKuweiMapper;
import com.lxmes.base.domain.JcWarehouseinfoKuwei;
import com.lxmes.base.service.IJcWarehouseinfoKuweiService;

/**
 * 库位管理Service业务层处理
 * 
 * @author 张志煜
 * @date 2022-11-17
 */
@Service
public class JcWarehouseinfoKuweiServiceImpl implements IJcWarehouseinfoKuweiService 
{
    @Autowired
    private JcWarehouseinfoKuweiMapper jcWarehouseinfoKuweiMapper;

    /**
     * 查询库位管理
     * 
     * @param id 库位管理主键
     * @return 库位管理
     */
    @Override
    public JcWarehouseinfoKuwei selectJcWarehouseinfoKuweiById(Long id)
    {
        return jcWarehouseinfoKuweiMapper.selectJcWarehouseinfoKuweiById(id);
    }

    @Override
    public JcWarehouseinfoKuwei selectJcWarehouseinfoKuweiByKuweiJmCode(String kuweiJmCode) {
        return jcWarehouseinfoKuweiMapper.selectJcWarehouseinfoKuweiByKuweiJmCode(kuweiJmCode);
    }

    /**
     * 查询库位管理列表
     * 
     * @param jcWarehouseinfoKuwei 库位管理
     * @return 库位管理
     */
    @Override
    public List<JcWarehouseinfoKuwei> selectJcWarehouseinfoKuweiList(JcWarehouseinfoKuwei jcWarehouseinfoKuwei)
    {
        jcWarehouseinfoKuwei.setTenantId(SecurityUtils.getFactoryCode());
        return jcWarehouseinfoKuweiMapper.selectJcWarehouseinfoKuweiList(jcWarehouseinfoKuwei);
    }
    //查询所有库位
    @Override
    public List<JcWarehouseinfoKuwei> selectJcWarehouseinfoKuQuList(JcWarehouseinfoKuwei jcWarehouseinfoKuwei) {
        jcWarehouseinfoKuwei.setTenantId(SecurityUtils.getFactoryCode());
        return jcWarehouseinfoKuweiMapper.selectJcWarehouseinfoKuQuList(jcWarehouseinfoKuwei);
    }

    /**
     * 新增库位管理
     * 
     * @param jcWarehouseinfoKuwei 库位管理
     * @return 结果
     */
    @Override
    public int insertJcWarehouseinfoKuwei(JcWarehouseinfoKuwei jcWarehouseinfoKuwei)
    {
        if(jcWarehouseinfoKuweiMapper.selectJcWarehouseinfoKuweiVerif(jcWarehouseinfoKuwei)>0){
            throw new ServiceException("库位码或库位简码不能重复");
        }
        jcWarehouseinfoKuwei.setTenantId(SecurityUtils.getFactoryCode());
        return jcWarehouseinfoKuweiMapper.insertJcWarehouseinfoKuwei(jcWarehouseinfoKuwei);
    }

    /**
     * 修改库位管理
     * 
     * @param jcWarehouseinfoKuwei 库位管理
     * @return 结果
     */
    @Override
    public int updateJcWarehouseinfoKuwei(JcWarehouseinfoKuwei jcWarehouseinfoKuwei)
    {
        if(jcWarehouseinfoKuweiMapper.selectJcWarehouseinfoKuweiVerif(jcWarehouseinfoKuwei)>0){
            throw new ServiceException("库位码或库位简码不能重复");
        }
        return jcWarehouseinfoKuweiMapper.updateJcWarehouseinfoKuwei(jcWarehouseinfoKuwei);
    }

    /**
     * 批量删除库位管理
     * 
     * @param ids 需要删除的库位管理主键
     * @return 结果
     */
    @Override
    public int deleteJcWarehouseinfoKuweiByIds(Long[] ids)
    {
        return jcWarehouseinfoKuweiMapper.deleteJcWarehouseinfoKuweiByIds(ids);
    }

    /**
     * 删除库位管理信息
     * 
     * @param id 库位管理主键
     * @return 结果
     */
    @Override
    public int deleteJcWarehouseinfoKuweiById(Long id)
    {
        return jcWarehouseinfoKuweiMapper.deleteJcWarehouseinfoKuweiById(id);
    }
}
